import LoginLayout from '@/layouts/LoginLayout.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import Login from '@/views/Login';
import Overview from '@/views/Overview';
import ProfileSettings from '@/views/ProfileSettings';
import InnerLayout from '@/layouts/InnerLayout.vue';
import EventLogs from '@/views/Diagnostic/EventLogs';
import PostCodeLogs from '@/views/Diagnostic/PostCodeLogs';
import SystemInformation from '@/views/SystemManagement/SystemInformation';
import Sensors from '@/views/SystemManagement/Sensors';
import RebootBmc from '@/views/Settings/RebootBmc';
import Policies from '@/views/UserSecurity/Policies';
import Sessions from '@/views/UserSecurity/Sessions';
import FactoryReset from '@/views/Services/FactoryReset';
import PowerRestorePolicy from '@/views/Settings/PowerRestorePolicy';
import Power from '@/views/SystemManagement/Power';
import Ldap from '@/views/UserSecurity/Ldap';
import Certificates from '@/views/UserSecurity/Certificates';
import UserManagement from '@/views/UserSecurity/UserManagement';
import Network from '@/views/Settings/Network';
import Firmware from '@/views/Settings/Firmware';
import Kvm from '@/views/Services/Kvm';
import SerialOverLan from '@/views/Services/SerialOverLan';
import ServerPowerOperations from '@/views/Settings/ServerPowerOperations';
import VirtualMedia from '@/views/Services/VirtualMedia';
import DateTime from '@/views/Settings/DateTime';

import PageNotFound from '@/views/PageNotFound';
import i18n from '@/i18n';
const { t } = i18n.global as any;

const roles = {
  administrator: 'Administrator',
  operator: 'Operator',
  readonly: 'ReadOnly',
  noaccess: 'NoAccess',
};

export default [
  {
    path: '/login',
    component: LoginLayout,
    children: [
      {
        path: '',
        name: 'Login',
        component: Login,
        meta: {
          title: computed(() => t('appPageTitle.login')),
        },
      },
    ],
  },
  {
    path: '/',
    meta: {
      requiresAuth: true,
    },
    component: AppLayout,
    children: [
      {
        path: '',
        name: 'Overview',
        component: Overview,
        meta: {
          title: computed(() => t('appPageTitle.overview')),
        },
      },
      {
        path: '',
        name: 'InnerLayout',
        component: InnerLayout,
        children: [
          {
            path: '/:pathMatch(.*)',
            name: 'page-not-found',
            component: PageNotFound,
            meta: {
              title: computed(() => t('appPageTitle.pageNotFound')),
            },
          },
          {
            path: '/system-management/system-information',
            name: 'system-information',
            component: SystemInformation,
            meta: {
              title: computed(() => t('appPageTitle.inventory')),
            },
          },
          {
            path: '/system-management/power',
            name: 'power',
            component: Power,
            meta: {
              title: computed(() => t('appPageTitle.power')),
            },
          },
          {
            path: '/system-management/sensors',
            name: 'sensors',
            component: Sensors,
            meta: {
              title: computed(() => t('appPageTitle.sensors')),
            },
          },
          {
            path: '/diagnostic/event-logs',
            name: 'event-logs',
            component: EventLogs,
            meta: {
              title: computed(() => t('appPageTitle.eventLogs')),
            },
          },
          {
            path: '/diagnostic/post-code-logs',
            name: 'post-code-logs',
            component: PostCodeLogs,
            meta: {
              title: computed(() => t('appPageTitle.postCodeLogs')),
            },
          },
          {
            path: '/user-security/sessions',
            name: 'sessions',
            component: Sessions,
            meta: {
              title: computed(() => t('appPageTitle.sessions')),
            },
          },
          {
            path: '/user-security/ldap',
            name: 'ldap',
            component: Ldap,
            meta: {
              title: computed(() => t('appPageTitle.ldap')),
            },
          },
          {
            path: '/user-security/user-management',
            name: 'local-users',
            component: UserManagement,
            meta: {
              title: computed(() => t('appPageTitle.userManagement')),
            },
          },
          {
            path: '/user-security/certificates',
            name: 'certificates',
            component: Certificates,
            meta: {
              title: computed(() => t('appPageTitle.certificates')),
            },
          },
          {
            path: '/user-security/policies',
            name: 'policies',
            component: Policies,
            meta: {
              title: computed(() => t('appPageTitle.policies')),
            },
          },
          {
            path: '/services/factory-reset',
            name: 'factory-reset',
            component: FactoryReset,
            meta: {
              title: computed(() => t('appPageTitle.factoryReset')),
            },
          },
          {
            path: '/services/kvm',
            name: 'kvm',
            component: Kvm,
            meta: {
              title: computed(() => t('appPageTitle.kvm')),
              exclusiveToRoles: [roles.administrator],
            },
          },
          {
            path: '/services/serial-over-lan',
            name: 'serial-over-lan',
            component: SerialOverLan,
            meta: {
              title: computed(() => t('appPageTitle.serialOverLan')),
              exclusiveToRoles: [roles.administrator],
            },
          },
          {
            path: '/profile-settings',
            name: 'profile-settings',
            component: ProfileSettings,
            meta: {
              title: computed(() => t('appPageTitle.profileSettings')),
            },
          },
          {
            path: '/services/virtual-media',
            name: 'virtual-media',
            component: VirtualMedia,
            meta: {
              title: computed(() => t('appPageTitle.virtualMedia')),
            },
          },
          {
            path: '/settings/network',
            name: 'network',
            component: Network,
            meta: {
              title: computed(() => t('appPageTitle.network')),
            },
          },
          {
            path: '/settings/firmware',
            name: 'firmware',
            component: Firmware,
            meta: {
              title: computed(() => t('appPageTitle.firmware')),
            },
          },
          {
            path: '/settings/date-time',
            name: 'date-time',
            component: DateTime,
            meta: {
              title: computed(() => t('appPageTitle.dateTime')),
            },
          },
          {
            path: '/settings/server-power-operations',
            name: 'server-power-operations',
            component: ServerPowerOperations,
            meta: {
              title: computed(() => t('appPageTitle.serverPowerOperations')),
            },
          },
          {
            path: '/settings/reboot-bmc',
            name: 'reboot-bmc',
            component: RebootBmc,
            meta: {
              title: computed(() => t('appPageTitle.rebootBmc')),
            },
          },
          {
            path: '/settings/power-restore-policy',
            name: 'power-restore-policy',
            component: PowerRestorePolicy,
            meta: {
              title: computed(() => t('appPageTitle.powerRestorePolicy')),
            },
          },
        ],
      },
    ],
  },
];
